<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Contributor</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="lib/fxsupport.js"></script>
<script type="text/javascript" src="lib/jquery-1.8.3.js"></script>
<script type="text/javascript" src="lib/JSResource.js"></script>
<script type="text/javascript" src="lib/urlpara.js"></script>
<!--[if lte IE 7]>
<style>
.content { margin-right: -1px; } /* 此 1px 负边距可以放置在此布局中的任何列中，且具有相同的校正效果。 */
ul.nav a { zoom: 1; }  /* 缩放属性将为 IE 提供其需要的 hasLayout 触发器，用于校正链接之间的额外空白 */
</style>
<![endif]-->
</head>

<body>

	<div class="container">
		<div class="header">
			<a href="#"><img src="logo.jpg" alt="在此处插入徽标" name="Insert_logo"
				width="20%" height="90" id="Insert_logo"
				style="background-color: #8090AB; display:block;" /> </a>
			<!-- end .header -->
		</div>
		<div class="sidebar1">
			<ul class="nav">
				<li><a href="home.jsp">Department Home</a></li>
				<li><a href="contributorlist.htm">Contributor List</a></li>
				<li><a href="memberlist.htm">Member List</a></li>
			</ul>
			<!-- end .sidebar1 -->
		</div>
		<div class="content">
			<form name="form">
				id: <input type="text" name="id" id="id"><br> name: <input
					type="text" name="name" id="name"><br> size: <input
					type="text" name="size" id="size"><br> type: <select
					name="type" id="type">
					<option value="com" selected>company</option>
					<option value="gov">government</option>
					<option value="edu">education</option>
					<option value="org">organization</option>
					<option value="pri">private</option>
				</select><br> <input id="commit" name="commit" type="button"
					value="submit" onClick="commitPage()">
			</form>
			<!-- end .content -->
		</div>
		<div class="footer">
			<!-- end .footer -->
		</div>
		<!-- end .container -->
	</div>
	<script type="text/javascript">
		var id = getParamFromURL("id");
		if (id != "") {
			resource.GET("contract/contributor/" + id, function() {
				document.getElementById("id").value = id;
				document.getElementById("id").disabled = true;
				document.getElementById("name").value = resource
						.getColumnValue("name");
				document.getElementById("size").value = resource
						.getColumnValue("size");
				document.getElementById("type").selectedIndex = resource
						.getChildren()[0].getChildren()[0]
						.getColumnValue("primarykey") - 1;
				document.getElementById("type").disabled = true;
			});
		}
		function commitPage() {
			var name = document.getElementById("name").value;
			var size = document.getElementById("size").value;
			if (checkIfNull(name) || checkIfNull(size)) {
				alert("Please fill in all the blanks!");
				return;
			}
			if (!checkIfFloat(size)) {
				alert("Size should be a float value!");
				return;
			}
			if (id != "") {
				putContributor(id, name, size, reloadReferrer);
			} else {
				id = document.getElementById("id").value;
				if (id == "") {
					alert("Please fill in all the blanks!");
					return;
				}
				if (!checkIfInt(id)) {
					alert("Id should be an integer value!");
					id = "";
					return;
				}
				resource.GET("contract/contributor/" + id, function() {
					if (resource.getColumns().length != 0) {
						alert("This id exists. Please choose another id!");
						id = "";
						return;
					}
					postContributor(id, name, size, document
							.getElementById("type").selectedIndex + 1,
							reloadReferrer);
				});
			}
		}
	</script>
</body>
</html>
